package ru.stepuk.modeller.buffers;

import java.util.Deque;
import java.util.LinkedList;
import ru.stepuk.modeller.Request;

/**
 *
 * @author ivan
 */
public class Queue extends Buffer {

    public Queue(int capacity) {
        this.capacity = capacity;
        this.container = new LinkedList<Request>();
    }

    @Override
    public void putRequest(Request request) throws FullQueueException {
        if (!hasFreeSpace()) {
            throw new FullQueueException();
        } else {
            ((Deque<Request>) container).offerLast(request);
        }
    }

    @Override
    public Request getRequest() {
        return ((Deque<Request>) container).pollFirst();
    }
}
